<?php
	$root = $_SERVER['DOCUMENT_ROOT'];
	include($root . "/util/session.php");//checks that the user is logged in
	include($root . "/util/privilege_check.php");
	checkPrivilege("student");
	//$query = "SELECT  FROM subjects join users on users.username = students_subjects.studentID join students_subjects ";
	$curuser=$_SESSION['login_user'];
	$query = "SELECT subjects.subjectName from subjects where subjects.subjectID in (select students_subjects.subjectID from students_subjects where students_subjects.studentID='$curuser')";
	$result = mysqli_query($db,$query);
	if(mysqli_num_rows($result) < 1){
		$error = "No users, how did you get here?";
	}

	#$row=mysqli_fetch_assoc($result);
	#echo $row['subjectID'];
?>

<html>
	<head>
		<title>Check and do exams</title>
		<link rel="stylesheet" type="text/css" href="studentStyle.css">
	</head>
	<body>
		<?php
			include($root . "/student/header.php")
		?>
		<li><a href="/student/student.php">Back</a></li>
		<div id="menu">
			<ul>
				<b>Subjects</b>
					<?php
						while($row = mysqli_fetch_assoc($result)){
							echo '<form action="/student/subjectExams.php" method="POST">' .
					        '<input type="submit" value="' . $row["subjectName"] . '" name="actualSubject"></form>';
						}
					?>
			</ul>
		</div>

		<?php
			include($root . "/student/footer.php")
		?>
	</body>
</html>
